<?php

/**
 * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
 * Copyright (c) 2010 Mr. Ynk: http://www.mrynk.nl
 */

/**
 * @author Michel Ypma: michel@mrynk.nl
 */

class SchemaUtils {

    public static function checkSchemas( $defs )
    {
        $rtn = array();
        foreach( $defs as $def )
        {
            if ( file_exists( MYTO_SCHEMA.'to-'.$def.'.xml' ) )
            {
                $rtn[] = MYTO_SCHEMA.'to-'.$def.'.xml';
            } else {
                throw new Exception('Myto was unable to locate (to-'.$def.'.xml)', 1024 );
            }
        }
        return $rtn;
    }

    public static function allSchemas()
    {
        $rtn = array();
        $dir = new DirectoryIterator( MYTO_SCHEMA );
        foreach( $dir as $file )
        {
            if ( !$file->isDot() &&
                 !$file->isDir() &&
                 substr( $file->getFilename(),0,3) == 'to-' &&
                 substr( $file->getFilename(), -4 ) == '.xml' )
            {
                $rtn[] = MYTO_SCHEMA.$file->getFilename();
            }
        }
        return $rtn;
    }

}

?>